﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Yaml;

namespace Medhurst.Unity.Configuration.Models
{
    public static class YamlNodeExtensions
    {
        public static string Scalar(this YamlNode node)
        {
            if (node is YamlScalar)
                return ((YamlScalar)node).Value;
            else
                return node.ToString();
        }

        public static YamlMapping AsMapping(this YamlNode node)
        {
            return ((YamlMapping)node);
        }

        public static YamlSequence AsSequence(this YamlNode node)
        {
            return ((YamlSequence)node);
        }

        public static bool IsMapping(this YamlNode node)
        {
            return node is YamlMapping;
        }

        public static bool IsSequence(this YamlNode node)
        {
            return node is YamlSequence;
        }
    }
}
